<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增分类')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal m" id="form-category-add">
        	<div class="row">
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label is-required">栏目名称：</label>
		                <div class="col-sm-8">
		                    <input name="categoryTitle" class="form-control" type="text" required>
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
		            <div class="form-group">    
		                <label class="col-sm-3 control-label">所属栏目：</label>
		                <div class="col-sm-8">
		                    <div class="input-group">
		                        <input id="treeId" name="categoryId" type="hidden" th:value="${cmsCategory?.id}"/>
		                        <input class="form-control" type="text" onclick="selectCategoryTree()" id="treeName" readonly="true" th:value="${cmsCategory?.categoryTitle}">
		                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
		                    </div>
		                </div>
		            </div>
        		</div>
        	</div>
        	<div class="row">
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label">栏目类型：</label>
		                <div class="col-sm-8">
		                	<div class="radio-box" th:each="dict : ${@dict.getType('cms_category_type')}">
								<input type="radio" th:id="${dict.dictCode}" name="categoryType" th:value="${dict.dictValue}" th:checked="${dict.default}">
								<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
							</div>
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label">自定义顺序：</label>
		                <div class="col-sm-8">
		                    <input name="categorySort" class="form-control" type="number">
		                </div>
		            </div>
        		</div>
        	</div>
        	<div class="row">
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label">列表模板：</label>
		                <div class="col-sm-8">
		                	<input name="categoryListUrl" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label">内容模板：</label>
		                <div class="col-sm-8">
		                    <input name="categoryUrl" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        	</div>
        	<div class="row">
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label">自定义链接：</label>
		                <div class="col-sm-8">
		                    <input name="categoryDiyUrl" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        	</div>
        	<div class="row">
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label">自定义模型：</label>
		                <div class="col-sm-8">
		                	<input name="mdiyModelId" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
        			<div class="form-group">    
		                <label class="col-sm-3 control-label">拼音：</label>
		                <div class="col-sm-8">
		                    <input name="categoryPinyin" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        	</div>
        	<div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">关键字<a  data-toggle="tooltip" title="<h4>提示</h4><p>{cms:global.descrip}</p>" data-html="true" data-trigger="hover" data-container = "body"><i class="fa fa-question-circle"></i></a>：</label>
                        <div class="col-xs-10">
                           <textarea name="categoryKeyword" class="form-control" ></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">栏目描述<a  data-toggle="tooltip" title="<h4>提示</h4><p>{cms:global.descrip}</p>" data-html="true" data-trigger="hover" data-container = "body"><i class="fa fa-question-circle"></i></a>：</label>
                        <div class="col-xs-10">
                            <textarea name="categoryDescrip" class="form-control"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
		            <div class="form-group">
		                <label class="col-sm-2 control-label">缩略图：</label>
		                <div class="col-sm-10">
		                    <div class="file-loading">
								<input name="categoryImg" id = "fileinput" type="file" multiple data-min-file-count="1">
							</div>
		                </div>
		            </div>
            	</div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
        var prefix = ctx + "cms/category"
        $("#form-category-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-category-add').serialize());
            }
        }

      

        /*分类-新增-选择父部门树*/
        function selectCategoryTree() {
            var options = {
                title: '分类选择',
                width: "380",
                url: prefix + "/selectCategoryTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
               $("#treeId").val(body.find('#treeId').val());
               $("#treeName").val(body.find('#treeName').val());
               layer.close(index);
        }
        
        
        $(document).ready(function () {
            $("#fileinput").fileinput({
                'theme': 'explorer-fas',
                'uploadUrl': '#',
                overwriteInitial: false,
                initialPreviewAsData: false
               
            });
        });
    </script>
</body>
</html>